package com.zing.network.net;

import io.reactivex.ObservableTransformer;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;

/**
 * @author jichang
 * @date 2018/9/19 20:11
 * email: 2218982471@qq.com
 * describ:
 */
public class RxUtil {/**
 * 统一线程处理
 *
 * @param <T> 指定的泛型类型
 * @return ObservableTransformer
 */
public static <T> ObservableTransformer<T, T> rxSchedulerHelper() {
    return observable -> observable.subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread());
}

    /**
     * 泛型转换工具方法 eg:object ==> map<String, String>
     *
     * @param object Object
     * @param <T> 转换得到的泛型对象
     * @return T
     */
    @SuppressWarnings("unchecked")
    public static <T> T cast(Object object) {
        return (T) object;
    }}
